﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Electrical 1.1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/box/layui/css/layui.css">
    <link rel="stylesheet" href="/box/assets/css/loader-style.css">
    <link rel="stylesheet" href="/box/assets/css/bootstrap.css">
    <link rel="stylesheet" href="/box/assets/css/signin.css">
    <script type="text/javascript" src="/box/assets/js/jquery.js"></script>
    <script type="text/javascript" src="/box/assets/js/preloader.js"></script>
    <script type="text/javascript" src="/box/assets/js/bootstrap.js"></script>
    <script type="text/javascript" src="/box/assets/js/load.js"></script>
    <script src="/box/layui/layui.js"></script>
    <script src="/box/js/config.js"></script>
    <script src="/box/js/json2.js"></script>
    <link rel="shortcut icon" href="box/assets/ico/minus.png">
    <style>
        * {
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div class="container">
        <div id="login-wrapper">
            <div class="row">
                <div class="col-md-4 col-md-offset-4">
                    <div id="logo-login">
                        <h1>
                            电器销售管理系统
                            <span>v1.1</span>
                        </h1>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 col-md-offset-4">
                    <div class="account-box"> 
                        <form class="layui-form">
                            <div class="form-group">
                                <label for="ele_account">用户名</label>
                                <input type="text" id="ele_account" class="form-control" name="eleAccount">
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input type="password" id="password" class="form-control" name="password">
                            </div>
                            <button lay-submit lay-filter="login" class="btn btn-primary pull-right">登 录</button>
                        </form>
                        <a class="forgotLnk" href="box/index.html"></a>
                        <div class="row-block">
	                        <div class="row"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
 		<p>&nbsp;</p>
        <div style="text-align:center;margin:0 auto;">
            <h6 style="color:#fff;">Copyright(C)2020 yz.com All Rights Reserved<br />
				宅客科技有限公司 版权所有
            </h6>
        </div>
    </div>

    <script type="text/javascript">
        layui.use(["form", "layer", "jquery"], function () {
            var form = layui.form;
            var $ = layui.jquery;
            form.on('submit(login)', function (data) {
                $.ajax({
                    url: new Config().base_url + "/user/login",
                    data: data.field,
                    dataType: 'json',
                    type: 'post',
                    success: function (d) {
                        //  判断返回数据了没有
                        if (d.code == 0) {
                            //  登录之后，将返回的数据存到本地，使数据另类的提交到另一个页面
                            sessionStorage.setItem("login_user",JSON.stringify(d.data));
                            layer.msg('登录成功', {
                                icon: 1,
                                time: 500  //  1秒后关闭，默认3秒后关闭
                            }, function () {
                                location.href = "/box/index.html";
                            });
                        } else {
                            layer.msg(d.msg);
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>

</html>
